#define _CRT_SECURE_NO_WARNINGS 1
SL* cur1 = headA, * cur2 = headB;
int n1 = 1, n2 = 1;
while (cur1)
{
    n1++;
    cur1 = cur1->next;
}
while (cur2)
{
    n2++;
    cur2 = cur2->next;
}
int k = abs(n1 - n2);
SL* longlist = headA, * shortlist = headB;
if (n1 < n2)
{
    longlist = headB;
    shortlist = headA;
}
while (k--)
{
    longlist = longlist->next;
}
while (longlist && shortlist)
{
    if (longlist == shortlist)
    {
        return longlist;
    }
    longlist = longlist->next;
    shortlist = shortlist->next;
}
return NULL;